﻿//系统管理-->系统通知
//Create By:li 2014年9月29日17:24:40

//1.0 加载JqueryDatabase
jQuery(function ($) {
    
    var oTable1 = $('#sample-table-2').dataTable({
        "aoColumns": [
          { "bSortable": false },
          { "bSortable": true },
          { "bSortable": false },
          { "bSortable": false },
          { "bSortable": false },
          { "bSortable": true },
          { "bSortable": false },
          { "bSortable": false },
          { "bSortable": false },
          //{ "bSortable": false },
          //{ "bSortable": false },
          //{ "bSortable": true },
          //{ "bSortable": true },
          { "bSortable": false },
          { "bSortable": false }
        ],
        oLanguage: {
            "sProcessing": "正在加载中......",
            "sLengthMenu": "每页显示 _MENU_ 条记录",
            "sZeroRecords": "对不起，查询不到相关数据！",
            "sEmptyTable": "表中无数据存在！",
            "sInfo": "当前显示： _START_ 到 _END_ 条，共 _TOTAL_ 条",
            "sInfoFiltered": "数据表中共为 _MAX_ 条记录",
            "sSearch": "",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上一页",
                "sNext": "下一页",
                "sLast": "末页"
            }
        },
        iDisplayLength: 10,
        bLengthChange: false
    });


    $('table th input:checkbox').on('click', function () {
        var that = this;
        $(this).closest('table').find('tr > td:first-child input:checkbox')
        .each(function () {
            this.checked = that.checked;
            $(this).closest('tr').toggleClass('selected');
        });

    });


    $('[data-rel="tooltip"]').tooltip({ placement: tooltip_placement });
    function tooltip_placement(context, source) {
        var $source = $(source);
        var $parent = $source.closest('table')
        var off1 = $parent.offset();
        var w1 = $parent.width();

        var off2 = $source.offset();
        var w2 = $source.width();

        if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
        return 'left';
    }
})

//3.10存量明细
function btnDetailClick(id) {

    window.window.location.href = "../BillStorehouse/BillInfo?id=" + id + "&productID=";
}

window.onload = function () {

    
 
    //2.0 页面初始化
    //2.1 给table加按钮（增加，审核，生效，停止，注销，购买产品，存量明细）
//    var $aa = $("#sample-table-2_wrapper .col-sm-6").eq(0);
//    $aa.html("<button class='btn btn-primary btn-sm' id='butadd'><i class='icon-plus-sign bigger-110'></i><span class='bigger-110 no-text-shadow'>新增</span></button>");
    //$aa.append("<button class='btn btn-danger btn-sm' style='margin-left: 4px' id='butdel'><i class='icon-trash bigger-110'></i><span class='bigger-110 no-text-shadow'>删除</span></button>");
    //$aa.append("<button class='btn btn-danger btn-sm' style='margin-left: 4px  ; display:none ' id='buttest'><i class='icon-trash bigger-110'></i><span class='bigger-110 no-text-shadow'>审核</span></button>");
    //$aa.append("<button class='btn btn-danger btn-sm' style='margin-left: 4px' id='butactive'><i class='icon-trash bigger-110'></i><span class='bigger-110 no-text-shadow'>生效</span></button>");
    //$aa.append("<button class='btn btn-sm btn-info no-radius' style='margin-left: 4px' id='butregister'><i class='icon-share-alt bigger-110'></i><span class='bigger-110 no-text-shadow'>注销</span></button>");
    //$aa.append("<button class='btn btn-sm' style='margin-left: 4px' id='butstop'><i class='icon-undo bigger-110'></i><span class='bigger-110 no-text-shadow'>停止</span></button>");
//    $aa.append("<button class='btn btn-success btn-sm' style='margin-left: 4px' id='buflush'><i class='icon-refresh bigger-110'></i><span class='bigger-110 no-text-shadow'>刷新</span></button>");
    //$aa.append("<button class='btn btn-sm' style='margin-left: 4px' id='butbuy'><i class='icon-shopping-cart bigger-110'></i><span class='bigger-110 no-text-shadow'>购买产品</span></button>");
    //$aa.append("<button class='btn btn-danger btn-sm' style='margin-left: 4px' id='butsave'><i class='icon-beaker bigger-110'></i><span class='bigger-110 no-text-shadow'>存量明细</span></button>");
//    $("td").addClass("tdBorder");
    //search
   $("#DicValue").select2();

    //2.2 table表头上的样式
    $("#sample-table-2>thead tr>th").attr("style", "font-weight:bold;color:black;text-align:center");



    //2.3 table搜索样式
    $("#sample-table-2_filter label input").attr("placeholder", "搜索(多条件搜索中间用空格隔开)").attr("style", "width:50%");
    $("#sample-table-2_filter label").attr("style", "width:100%");

    $("#sample-table-2_filter").attr("style", "margin-right: -16px;");
    $("#sample-table-2_wrapper .row").first().children().eq(1).attr("style", "margin-top:-12px");
    $("#sample-table-2_wrapper").attr("style", "margin-top:-32px");
    $("#butadd").attr("style", "margin-top:-4px");

    //2.4 增加表单行间距样式
    $("div .modal-body .row:not(#iconr)").attr("style", "margin-top:7px;");
    $("div .modal-body .row .col-sm-3").attr("style", "margin-top:6px;text-align:right");
    $("div#myModal .modal-body .row i:lt(6)").attr("style", "margin-top:9px;text-align:right;");
    $("div#myModalBuy .modal-body .row i:lt(6)").attr("style", "margin-top:9px;text-align:right;");
    $("#form_field_select_4_chosen").attr("style", "width:100%");
    //2.5 具有审核权限显示审核按钮
    $.ajax({
        url: "Display",
        dataType: "Json",
        data: {},
        Type: "Post",
        success: function (data) {
            var json = eval(data);
            if (json.result == "Success") {
                
                //$(".buthidden").removeAttr("style");
               

            }
            else {
                $("#sample-table-2 a.buttest1").removeAttr("style");
                $("#sample-table-2 a.buttest1").unbind("click");
                $("#sample-table-2 a.buttest1").removeAttr("href");
                $("#sample-table-2 a.buttest1").attr("style", "color:gray;cursor:not-allowed;");
               // $("#buttest").removeAttr("style").attr("style", "margin-left: 4px");
                 
            }
        }
    });
    
    //2.6 按钮样式
    $("button.btn.btn-sm:gt(0)").attr("style", "margin:-5px 0px 0px 4px");
    //2.7 显示页数一行的样式
    $("#sample-table-2").next().find(".col-sm-6").eq(0).attr("style", "margin-left: -12px;margin-top: 5px;");
    $("#sample-table-2").next().find(".col-sm-6").eq(1).attr("style", "margin-left: 12px;margin-top: 0px;");

    
    //3.0   功能
    //3.1   删除
    $("#butdel").click(function delCheck() {
        var idString = "";
        $("table tbody input[type='checkbox']:checked").parent().parent().next().each(function () {
            idString += $(this).text() + ","
        });
        idString = idString.substring(0, idString.length - 1);
        if (idString.length == 0) {
            $.gritter.add({
                title: '消息提醒',
                text: '请选择要删除的项',
                class_name: 'gritter-info gritter-center'
            });
        }
        else {
            if (!confirm("确定删除")) { return; }
            $.ajax({
                url: "ToDelete",
                dataType: "Json",
                data: { idString: idString },
                Type: "Post",
                success: function (data) {
                    var json = eval(data);
                    if (json.result == "Success") {
                        $.gritter.add({
                            title: '消息提醒',
                            text: json.message,
                            class_name: 'gritter-info gritter-center'
                        });
                        history.go(0);
                    }
                    else {
                        $.gritter.add({
                            title: '消息提醒',
                            text: json.message,
                            class_name: 'gritter-info gritter-center'
                        });
                    }
                }
            });
        }
    });

    //3.2   刷新
    $("#buflush").click(function () {
        history.go(0);
    });

    //3.3   点击新增按钮
    //3.3.1 点击新增按钮，初始化模态窗口
    function initForm() {
        $(".icon-lightbulb").attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
        // $("div#myModal .modal-body .row input:not([autocomplete])").val("").removeAttr("style");
        $(".form-control").val("").removeAttr("style");
        // $("div#myModal .modal-body .row i)").attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
        $("#UserAccount").val("").removeAttr("style");
       // $("#DicValue").val("").removeAttr("style");
       // $("#DicValue").select2("val", "800000");
        $("#s2id_DicValue").attr("style", "width:100%;height:34px;border: 1px solid #d5d5d5;");
        $(".select2-choice").attr("style", "height:32px;background-color: #fff;border:0;");


        //$("div#myModal .modal-body .row select:lt(1)").val("0").removeAttr("style");

        $("#but_saveadd").removeAttr("style");
        $("#but_savemodify").removeAttr("style").attr("style", "display:none");


        $("#LookPWD").attr("class", "btn btn-minier btn-white icon-eye-open");
        $("#UserPassword").attr("type", "password")



    }
    //3.3.2 启动模态窗口
    $("#butadd").click(function () {
        initForm();
        $("#myModal").modal();
    });
    //3.3.3 验证表单
    
    $("#ECName").focus(function () {
        $(this).removeAttr("style");
        $(this).parent().next().attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    });
    $("#ECName").blur(function () {
        var reg = /^[\u4e00-\u9fa5_a-zA-Z0-9]{1,30}$/;  //长度为1-30的汉英文数字下滑线
        var obj = $(this).val();
        if (!reg.test(obj)) {
            $(this).attr("style", " border-color: red;");
            $(this).parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");

        }
    });
    $("#ECShortName").focus(function () {
        $(this).removeAttr("style");
        $(this).parent().next().attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    });
    $("#ECShortName").blur(function () {
        var reg = /^[a-zA-Z0-9]{1,30}$/;  //长度为1-30的英文、数字
        var obj = $(this).val();
        if (!reg.test(obj)) {
            $(this).attr("style", " border-color: red;");
            $(this).parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");

        }
    });
    $("#DicValue").focus(function () {
        $(this).removeAttr("style");
        $(this).parent().next().attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    });
    $("#DicValue").blur(function () {

        if ($("#DicValue").val() == null) {
            $(this).attr("style", " border-color: red;");
            $(this).parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");

        }
    });
    $("#UserAccount").focus(function () {
        $(this).removeAttr("style");
        $(this).parent().next().attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    });
    $("#UserAccount").blur(function () {
        var reg = /^[a-zA-Z]{2,16}$/;  //长度为2-16的字母
        var obj = $(this).val();
        if (!reg.test(obj)) {
            $(this).attr("style", " border-color: red;");
            $(this).parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
        }
    });

    $("#UserPassword").focus(function () {
        $(this).removeAttr("style");
        $(this).parent().next().attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    });
    $("#UserPassword").blur(function () {
        var reg = /^\w{6,15}$/;
        var obj = $(this).val();
        if (!reg.test(obj)) {
            $(this).attr("style", " border-color: red;");
            $(this).parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");

        }
    });

    $("#LinkManMobile").focus(function () {
        $(this).removeAttr("style");
        $(this).parent().next().attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    });
    $("#LinkManMobile").blur(function () {
        var reg = /^1[358]\d{9}$/;
        var reg170 = /^170\d{8}$/;//手机验证
        var obj = $(this).val();
        if (!reg.test(obj) && !reg170.test(obj)) {
            $(this).attr("style", " border-color: red;");
            $(this).parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");

        }
    });

    $("#Email").focus(function () {
        $(this).removeAttr("style");
        $(this).parent().next().attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    });
    $("#Email").blur(function () {
        //var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        // var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
        var reg = /^([a-zA-Z0-9])+([-_.][a-zA-Z0-9]+)*@([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z0-9]{2,4}$/; //邮箱验证
        var obj = $(this).val();
        if (!reg.test(obj)) {
            $(this).attr("style", " border-color: red;");
            $(this).parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");

        }
    });
    $("#s2id_autogen1").attr("style", "width: 302px; height: 31px; font-size: 15px; font-family: 微软雅黑;");



    //3.4  新增保存
    function save() {


        /*
         *  下面两种获取节点内容的方式都可以。
         *  由于 IE6, IE7 不支持 contentDocument 属性，所以此处用了通用的
         *  window.frames["iframe Name"] or window.frames[index]
         */


        var UserAccount = $("#UserAccount").val();
        var ECName = $("#ECName").val();
        var ECShortName = $("#ECShortName").val();
        var DicValue = $("#DicValue").val();
        //var Status = $("#Status").val();
        var UserPassword = $("#UserPassword").val();
        var LinkManMobile = $("#LinkManMobile").val();
        var Email = $("#Email").val();
        var Description = $("#Description").val();


        var flag = true;


        if (1 == 1) {
            var reg = /^[\u4e00-\u9fa5_a-zA-Z0-9]{1,30}$/;  //长度为1-30的汉英文数字下滑线
            if (!reg.test(ECName)) {
                flag = false;
                $("#ECName").attr("style", " border-color: red;");
                $("#ECName").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "企业名称填写错误（长度为2-16的汉英文数字下滑线）";
            }
        }

        if (1 == 1 && flag) {
            var reg = /^[a-zA-Z0-9]{1,30}$/;  //长度为1-30的英文、数字
            if (!reg.test(ECShortName)) {
                flag = false;
                $("#ECShortName").attr("style", " border-color: red;");
                $("#ECShortName").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "企业简称填写错误（长度为1-30的英文字母）";
            }
        }
        if (1 == 1 && flag) {
            if (DicValue == null)
            {
                flag = false;
                $("#DicValue").attr("style", " border-color: red;");
                $("#DicValue").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "所属代理商填写错误";
            }
             
        }

        if (1 == 1 && flag) {
            var reg = /^[a-zA-Z]{2,16}$/;  //长度为2-16的字母
            if (!reg.test(UserAccount)) {
                flag = false;
                $("#UserAccount").attr("style", " border-color: red;");
                $("#UserAccount").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "登陆账户名填写错误（长度为2-16的字母）";
            }
        }

        if (1 == 1 && flag) {
            var reg = /^\w{6,15}$/;
            if (!reg.test(UserPassword)) {
                flag = false;
                $("#UserPassword").attr("style", " border-color: red;");
                $("#UserPassword").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "密码填写错误（长度为6-15）";
            }
        }

        if (1 == 1 && flag) {
            var reg = /^1[358]\d{9}$/;
            var reg170 = /^170\d{8}$/;
            if (!reg.test(LinkManMobile) && !reg170.test(LinkManMobile)) {
                flag = false;
                $("#LinkManMobile").attr("style", " border-color: red;");
                $("#LinkManMobile").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "手机号不存在";

            }
        }
        if (1 == 1 && flag) {
            //var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            // var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
            var reg = /^([a-zA-Z0-9])+([-_.][a-zA-Z0-9]+)*@([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z0-9]{2,4}$/;//邮箱验证
            if (!reg.test(Email)) {
                flag = false;
                $("#Email").attr("style", " border-color: red;");
                $("#Email").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "邮箱不存在";
            }
        }
        if (!flag) {
            $.gritter.add({
                title: '消息提醒',
                text: msg,
                class_name: 'gritter-info gritter-center'
            });
            return;
        }

        $.ajax({
            url: "AddNewECECC",
            dataType: "json",
            Type: "POST",
            data: {
                UserAccount: UserAccount,
                ECName: ECName,
                ECShortName: ECShortName,
                DicValue: DicValue,
                UserPassword: UserPassword,
                LinkManMobile: LinkManMobile,
                Email: Email,
                Description: Description

            },
            success: function (data) {
                var json = eval(data);
                if (json.result == "Success") {


                    $("#but_infoclose").click();
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });

                    history.go(0);

                }
                else {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                }
            }
        });
    }
    $("#but_saveadd").click(function () {

        save();
    });


    //3.5.2 保存修改
    function savemodify() {

        //var MSGCountent = document.getElementById("editor1").innerHTML.toString();
        var ECECCID = $("#idHidden").val();
        var UserAccount = $("#UserAccount").val();
        var ECName = $("#ECName").val();
        var ECShortName = $("#ECShortName").val();
        var DicValue = $("#DicValue").val();
        var UserPassword = $("#UserPassword").val();
        var LinkManMobile = $("#LinkManMobile").val();
        var Email = $("#Email").val();
        var Description = $("#Description").val();
        //var Status = $("#Status").val();



        var flag = true;


        if (1 == 1) {
            var reg = /^[\u4e00-\u9fa5_a-zA-Z0-9]{1,30}$/;  //长度为1-30的汉英文数字下滑线
            if (!reg.test(ECName)) {
                flag = false;
                $("#ECName").attr("style", " border-color: red;");
                $("#ECName").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "企业名称填写错误（长度为1-30的汉英文数字下滑线）";
            }
        }

        if (1 == 1 && flag) {
            var reg = /^[a-zA-Z0-9]{1,30}$/;  //长度为1-30的英文、数字
            if (!reg.test(ECShortName)) {
                flag = false;
                $("#ECShortName").attr("style", " border-color: red;");
                $("#ECShortName").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "企业简称填写错误（长度为1-30的英文字母）";
            }
        }
        if (1 == 1 && flag) {
            if (DicValue == "") {
                flag = false;
                $("#DicValue").attr("style", " border-color: red;");
                $("#DicValue").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "所属代理商填写错误";
            }

        }
        if (1 == 1 && flag) {
            var reg = /^[a-zA-Z]{2,16}$/;  //长度为2-16的字母
            if (!reg.test(UserAccount)) {
                flag = false;
                $("#UserAccount").attr("style", " border-color: red;");
                $("#UserAccount").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "登陆账户名填写错误（长度为2-16的字母）";
            }
        }

        if (1 == 1 && flag) {
            var reg = /^\w{6,15}$/;
            if (!reg.test(UserPassword)) {
                flag = false;
                $("#UserPassword").attr("style", " border-color: red;");
                $("#UserPassword").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "密码填写错误（长度为6-15）";
            }
        }

        if (1 == 1 && flag) {
            var reg = /^1[358]\d{9}$/;
            var reg170 = /^170\d{8}$/;
            if (!reg.test(LinkManMobile) && !reg170.test(LinkManMobile)) {
                flag = false;
                $("#LinkManMobile").attr("style", " border-color: red;");
                $("#LinkManMobile").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "手机号不存在";
            }
        }

        if (1 == 1 && flag) {
            // var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
            var reg = /^([a-zA-Z0-9])+([-_.][a-zA-Z0-9]+)*@([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z0-9]{2,4}$/
            if (!reg.test(Email)) {
                flag = false;
                $("#Email").attr("style", " border-color: red;");
                $("#Email").parent().next().attr("class", "icon-lightbulb cuitooltip tooltip-error icon-animated-vertical red");
                msg = "邮箱不存在";
            }
        }
        if (!flag) {
            $.gritter.add({
                title: '消息提醒',
                text: msg,
                class_name: 'gritter-info gritter-center'
            });
            return;
        }



        $.ajax({
            url: "SaveModifyECECC",
            dataType: "json",
            Type: "POST",
            data: {
                ECECCID: ECECCID,
                UserAccount: UserAccount,
                ECName: ECName,
                ECShortName: ECShortName,
                DicValue: DicValue,
                UserPassword: UserPassword,
                LinkManMobile: LinkManMobile,
                Email: Email,
                Description: Description
            },
            success: function (data) {

                var json = eval(data);
                if (json.result == "Success") {

                    //alert(json.obj);

                    $("#but_infoclose").click();
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                    window.location.href = "../ECECC/ECECCIndex";



                }
                else {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                }
            }
        }
        );

    }
    $("#but_savemodify").click(function () {
        savemodify();
    }
    ); 
    //3.10  点击查看密码按钮
    $("#LookPWD").click(function () {
        if ($(this).hasClass("icon-eye-close")) {
            $(this).removeClass("icon-eye-close").addClass("icon-eye-open");
            $("#UserPassword").attr("type", "password");
            $("#UserPassword1").attr("type", "password");
        }
        else {
            $(this).removeClass("icon-eye-open").addClass("icon-eye-close");
            $("#UserPassword").attr("type", "text");
            $("#UserPassword1").attr("type", "text");
        }
    });


    $("#bgdiv").attr("style", "display:none");


}
//3.6 审核

$("#sample-table-2 a.buttest1").click(function testCheck() {
    // var idString = "";
    var status = 1;
    // $("table tbody input[type='checkbox']:checked").parent().parent().next().each(function () {
    //     idString += $(this).text() + ","
    // });
    // idString = idString.substring(0, idString.length - 1);
    var idString = $(this).parent().parent().parent().parent().parent().children().eq(1).text()
    if (idString.length == 0) {
        $.gritter.add({
            title: '消息提醒',
            text: '请选择要操作的项',
            class_name: 'gritter-info gritter-center'
        });
    }
    else {
        if (!confirm("确定审核通过（审核通过以后既可使用分配到的功能）")) { return; }
        $.ajax({
            url: "ToGetStopOrRegister",
            dataType: "Json",
            data: {
                idString: idString,
                Status: status
            },
            Type: "Post",
            success: function (data) {
                var json = eval(data);
                if (json.result == "Success") {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                    //history.go(0);
                    window.location.href = "../ECECC/ECECCIndex";
                }
                else {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                }
            }
        });
    }
}
);
//3.7 生效

$("#sample-table-2 a.butactive1").click(function testCheck() {
    // var idString = "";
    var status = 1;
    // $("table tbody input[type='checkbox']:checked").parent().parent().next().each(function () {
    //     idString += $(this).text() + ","
    // });
    // idString = idString.substring(0, idString.length - 1);
    var idString = $(this).parent().parent().parent().parent().parent().children().eq(1).text()
    if (idString.length == 0) {
        $.gritter.add({
            title: '消息提醒',
            text: '请选择要操作的项',
            class_name: 'gritter-info gritter-center'
        });
    }
    else {
        if (!confirm("确定生效（生效以后原有功能可恢复使用）")) { return; }
        $.ajax({
            url: "ToGetStopOrRegister",
            dataType: "Json",
            data: {
                idString: idString,
                Status: status
            },
            Type: "Post",
            success: function (data) {
                var json = eval(data);
                if (json.result == "Success") {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                    //history.go(0);
                    window.location.href = "../ECECC/ECECCIndex";
                }
                else {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                }
            }
        });
    }
}
);
//3.8 注销

$("#sample-table-2 a.butregister1").click(function sendCheck() {
    // var idString = "";
    var idString = $(this).parent().parent().parent().parent().parent().children().eq(1).text()
    var status = 4;
    // $("table tbody input[type='checkbox']:checked").parent().parent().next().each(function () {
    //      idString += $(this).text() + ","
    //   });
    //  idString = idString.substring(0, idString.length - 1);

    if (idString.length == 0) {
        $.gritter.add({
            title: '消息提醒',
            text: '请选择要操作的项',
            class_name: 'gritter-info gritter-center'
        });
    }
    else {
        if (!confirm("确定注销（所有功能禁用并从系统中删除）")) { return; }
        $.ajax({
            url: "ToGetStopOrRegister",
            dataType: "Json",
            data: {
                idString: idString,
                Status: status
            },
            Type: "Post",
            success: function (data) {
                var json = eval(data);
                if (json.result == "Success") {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                    // history.go();
                    window.location.href = "../ECECC/ECECCIndex";
                }
                else {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                }
            }
        });
    }
}
);


//3.9   停止
$("#sample-table-2 a.butstop1").click(function backCheck() {
    // var idString = "";
    var idString = $(this).parent().parent().parent().parent().parent().children().eq(1).text()
    var status = 3;
    // $("table tbody input[type='checkbox']:checked").parent().parent().next().each(function () {
    //      idString += $(this).text() + ","
    // });
    // idString = idString.substring(0, idString.length - 1);
    if (idString.length == 0) {
        $.gritter.add({
            title: '消息提醒',
            text: '请选择要操作的项',
            class_name: 'gritter-info gritter-center'
        });
    }
    else {
        if (!confirm("确定停止（所用功能均不可使用，待管理员重新启用可恢复使用）")) { return; }
        $.ajax({
            url: "ToGetStopOrRegister",
            dataType: "Json",
            data:
                {
                    idString: idString,
                    Status: status
                },
            Type: "Post",
            success: function (data) {
                var json = eval(data);
                if (json.result == "Success") {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                    window.location.href = "../ECECC/ECECCIndex";
                }
                else {
                    $.gritter.add({
                        title: '消息提醒',
                        text: json.message,
                        class_name: 'gritter-info gritter-center'
                    });
                }
            }
        });
    }
});
//3.5  修改
//3.5.1 修改初始化
//$("#sample-table-2 i.icon-pencil").click(function () {
$("#sample-table-2 a.Modify").click(function () {

    var id = $(this).parent().parent().parent().parent().parent().children().eq(1).text()
    initForm();
    $.ajax({
        url: "LoadECECCModify",
        datatype: "json",
        type: "post",
        data: {
            id: id
        },
        success: function (data) {
            var json = eval(data);

            $("#idHidden").val(json.ECECCID);
            $("#UserAccount").val(json.UserAccount);
            $("#ECName").val(json.ECName);
            $("#ECShortName").val(json.ECShortName);
            //$("#DicValue").val(json.AgentOwnerID);
            $("#DicValue").select2("val", json.AgentOwnerID);
            $("#UserPassword").val(json.UserPassword);

            $("#LinkManMobile").val(json.LinkManMobile);
            $("#Email").val(json.Email);
            $("#Description").val(json.Description);
            //new PCAS("province", "city", "area", json.Province, json.City, json.County)


            $("#but_saveadd").attr("style", "display:none");
            $("#but_savemodify").removeAttr("style");
            // $("#but_send").attr("style", "display:none");
            //$("#but_modifysend").removeAttr("style");
            $("#myModal").modal();
        }

    });
    
}

);

//3.3.1 点击新增按钮，初始化模态窗口
function initForm() {
    $(".icon-lightbulb").attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    // $("div#myModal .modal-body .row input:not([autocomplete])").val("").removeAttr("style");
    $(".form-control").val("").removeAttr("style");
    // $("div#myModal .modal-body .row i)").attr("class", "icon-lightbulb tooltip-success cuitooltip form-success");
    $("#UserAccount").val("").removeAttr("style");
    // $("#DicValue").val("").removeAttr("style");
    // $("#DicValue").select2("val", "800000");
    $("#s2id_DicValue").attr("style", "width:100%;height:34px;border: 1px solid #d5d5d5;");
    $(".select2-choice").attr("style", "height:32px;background-color: #fff;border:0;");


    //$("div#myModal .modal-body .row select:lt(1)").val("0").removeAttr("style");

    $("#but_saveadd").removeAttr("style");
    $("#but_savemodify").removeAttr("style").attr("style", "display:none");


    $("#LookPWD").attr("class", "btn btn-minier btn-white icon-eye-open");
    $("#UserPassword").attr("type", "password")



}
//function btnLoginWebClick(ecid)
//{
//    window.open("http://hykz"+ecid+".handbbc.com/base/admin/index.php");
//}
$(".KZProcuct").click(function () {
    var id = $(this).parent().parent().children().eq(1).text();
    window.open("http://hykz" + id + ".handbbc.com/base/admin/index.php");
});